package cn.bb.service;

import cn.bb.dao.IUserDao;
import cn.bb.model.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class IUserServiceImpl implements IUserService {
    @Resource
    private IUserDao userDao;
    @Override
    public Page queryLikeUsers(Map<String, Object> map) {
        Page page = new Page();
        //总条数
        page.setTotal(userDao.getLikeUserCount(map));
        //每页条数
        int pageSize =Integer.parseInt(String.valueOf(map.get("pageSize")));
        page.setPageSize(pageSize);
        //当前页数
        int pageNum =Integer.parseInt(String.valueOf(map.get("pageNum")));
        page.setPageNum(pageNum);
        page = PageHelper.startPage(pageNum,pageSize);
        List<User> list = userDao.getLikeUsers(map);
        return page;
    }
    public List<User> getAllUsers(){
        return userDao.getAllUser();
    }
    public IUserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }
}
